<template>
	<el-dialog :title="dialogTitle" :visible.sync="visible" top="0" width="560px" append-to-body>
		<el-form v-bind="formConfig" :model="formData" :rules="formRules" label-width="84px">
			<el-row :gutter="16" v-loading="loading">
				<el-col :span="24">
					<el-form-item label="角色类型" prop="type">
						<sw-dict-radio v-model="formData.type" dict-name="ROLE_TYPE" />
					</el-form-item>
				</el-col>
				<el-col :span="24">
					<el-form-item label="角色名称" prop="name">
						<el-input v-model="formData.name"></el-input>
					</el-form-item>
				</el-col>
				<el-col :span="24">
					<el-form-item label="角色描述">
						<el-input type="textarea" v-model="formData.content"></el-input>
					</el-form-item>
				</el-col>
			</el-row>
		</el-form>
		<template slot="footer">
			<el-button size="medium" @click="visible = false">取消</el-button>
			<el-button size="medium" type="primary" :loading="btnLoading" @click="handleSubmitForm">{{ formTypeName }}</el-button>
		</template>
	</el-dialog>
</template>

<script>
import formMixins from '@/mixins/formMixins';
import { roleDetail, addedRole, updateRole } from '@/api/system/tbSysRole';
export default {
	mixins: [formMixins],
	data() {
		return {
			formName: '角色',
			formRules: {
				type: [{ required: true, message: '请选择角色类型', trigger: 'change' }],
				name: [{ required: true, message: '请输入角色名称', trigger: 'blur' }]
			},
			btnLoading: false
		};
	},
	computed: {
		detailData() {
			return eval(roleDetail);
		},
		callFunction() {
			return eval(this.addOrEdit ? addedRole : updateRole);
		}
	},
	watch: {},
	methods: {}
};
</script>
